package web.req;

import common.consts.Consts;
import common.consts.Ratings;
import common.validation.ValidationResult;
import web.Request;

import javax.validation.constraints.Min;

/**
 * Created by Administrator on 2015/7/8.
 */
public class UserRatingEmpRequest extends Request {

    @Min(value = 1, message = Consts.i18nKey.INVALID_USER_ID)
    private long userId;
    @Min(value = 1, message = Consts.i18nKey.INVALID_EMPLOYER_ID)
    private long empId;
    @Min(value = 1, message = Consts.i18nKey.INVALID_RECRUITMENT_ID)
    private long recruitment;


    private String rate;//必填

    private String comment;


    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public long getEmpId() {
        return empId;
    }

    public void setEmpId(long empId) {
        this.empId = empId;
    }

    public long getRecruitment() {
        return recruitment;
    }

    public void setRecruitment(long recruitment) {
        this.recruitment = recruitment;
    }

    public String getRate() {
        return rate;
    }

    public void setRate(String rate) {
        this.rate = rate;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    @Override
    public ValidationResult validate() {
        //扫描注解
        ValidationResult result = super.validate();
        if (rate == null) {
            result.setSuccess(false);
            result.setMessage(Consts.i18nKey.INVALID_RATE_VALUE);
        } else {
            if (!Ratings.isValid(rate)) {
                result.setSuccess(false);
                result.setMessage(Consts.i18nKey.INVALID_RATE_VALUE);
            }
        }
        return result;
    }
}
